package com.djakapm.swing.component.textarea;

import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;

public class TextAreaContentChangeListener implements DocumentListener, ChangeListener {

    private TextAreaView tav;
    
    public TextAreaContentChangeListener(TextAreaView tav){
        this.tav = tav;
    }



    public void insertUpdate(DocumentEvent e) {
        this.tav.addLineNumber();
    }

    public void removeUpdate(DocumentEvent e) {
        this.tav.removeLineNumber();
    }

    public void changedUpdate(DocumentEvent e) {
        System.out.println("change");
    }

    public void stateChanged(ChangeEvent e) {
        this.tav.scroller.getViewport().revalidate();
        this.tav.scroller.getViewport().repaint();
    }
}
